/* $Id: perl.c,v 1.1 2006/03/19 20:13:52 jfb Exp $ */

#include <sys/types.h>

#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

#include <EXTERN.h>
#include <perl.h>

#include "module.h"
#include "mod_perl.h"



/*
* mod_perl_require()
*
* Perform the equivalent of the Perl 'require' statement but from within
* the mod_perl interpreter.
*/

int
mod_perl_require(struct perl_mod *pmod, const char *module)
{
	char buf[128];
	SV *sv;

	snprintf(buf, sizeof(buf), "require \"%s\"", module);

	PERL_SET_CONTEXT(pmod->interp);
	sv = sv_newmortal();
	if (sv == NULL) {
		return (-1);
	}

	sv_setpv(sv, buf);

	eval_sv(sv, G_DISCARD);

	return (0);
}
